import pymysql
from flask import Flask
from flask_cors import CORS

import config
from blueprints import *
from ext import db


def create_app():
    # init app
    app = Flask(__name__)
    app.config.from_object(config)
    db.init_app(app)

    # init db driver
    pymysql.install_as_MySQLdb()

    # set CORS
    CORS(app, supports_credentials=True)

    # register blueprints
    app.register_blueprint(hotel_bp)
    app.register_blueprint(room_bp)
    app.register_blueprint(notice_bp)
    app.register_blueprint(customer_bp)
    app.register_blueprint(order_bp)
    return app


if __name__ == '__main__':
    app = create_app()
    app.run()
